const jwt = require('jsonwebtoken')
const secret = 'asxfwxkocopfkmflbbb'


module.exports = {
    async siginToken(userinfo) {
        return await jwt.sign({
            ...userinfo
        }, secret, { expiresIn: '1h' });
    },
    async verifyToken(token) {
        return await jwt.verify(token, secret, function (err, decoded) {
            if (err) {
                return err.name
            } else {
                return decoded
            }
        });
    }
}

